<?php
namespace Home\Controller;
use Think\Controller;
class InvestorController extends BaseController{
	public function index(){
		if($_GET['p']==''){
			$_GET['p'] = 1;
		}
		$categoryInfo	= SearchOne('Category','flag',$THINK.CONTROLLER_NAME);
		$category_id	= $categoryInfo['id'];
		$map['category_id']	= array('EQ',$category_id);
		$list			= M('Article') -> where($map) -> order('is_index desc,add_time desc,id desc') -> page($_GET['p'].',15')  -> select();
		$count			= M('Article') -> where($map) -> count();
		$Pages			= new \Think\Pages($count, 15); 
		$Pages -> url	= U('/'.$THINK.CONTROLLER_NAME.'/list-'.urlencode('[PAGE]').'.html');
		$show			= $Pages -> show();
		$map['thumb']	= array('NEQ','');
		$photo			= M('Article') -> where($map) -> order('is_index desc,add_time desc,id desc') -> select();

		$this		-> assign('category_id',$category_id);
		$this		-> assign('categoryInfo',$categoryInfo);
		$this		-> assign('list',$list);
		$this		-> assign('pages',$show);
		$this		-> assign('photo',$photo);
		$this		-> display('investor');
	}
	public function view(){
		$id				= I('id');
		$categoryInfo	= SearchOne('Category','flag',$THINK.CONTROLLER_NAME);
		$category_id	= $categoryInfo['id'];
		$articleInfo	= SearchOne('Article','id',$id);
		$front			= M('Article') -> where(array("category_id" => $category_id,"id<".$id)) -> order('id desc') -> limit('1') -> find();  
		if(!$front){
			$f = '上一篇：没有了';
		}else{
			$f = '上一篇：<a href="detail-'.$front["id"].'.html" title="'.$front["title"].'">'.$front["title"].'</a>';
		}
		$after			= M('Article') -> where(array("category_id" => $category_id,"id>".$id)) -> order('id asc') -> limit('1') -> find();  
		if(!$after){
			$a = '下一篇：没有了';
		}else{
			$a = '下一篇：<a href="detail-'.$after["id"].'.html" title="'.$after["title"].'">'.$after["title"].'</a>';
		}

		$this -> assign('category_id',$category_id);
		$this -> assign('categoryInfo',$categoryInfo);
		$this -> assign('articleInfo',$articleInfo);
		$this -> assign('front',$f);
		$this -> assign('after',$a);
		$this -> display('view');
	}
}